
import java.util.ArrayList;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Comedy Option
 */
public class Building {
    
    private ArrayList<Floor> floors;
    
    public Building(int numFloors){
        floors = new ArrayList<Floor>();
        for(int i = 1; i <= numFloors; i++){
            floors.add(new Floor("" + i));
        }
    }
    
    public int getNumFloors(){
        return floors.size();
    }
            
    
    public Floor getFloorByIndex(int index){
        return floors.get(index);
    }
    
    public boolean addFloor(Floor newFloor){
        if (getFloorByName(newFloor.getName()) == null){
            floors.add(newFloor);
            return true;
        }
        return false;
    }
    
    public boolean addRoom(String floor, Room toAdd){
        Floor toCheck = getFloorByName(floor);
        if(toCheck != null){
            toCheck.addRoom(toAdd);
            return true;
        }
        return false;
        
    }
    
    public Floor getFloorByName(String name){
       Floor toCheck;
       for(int i = 0; i < floors.size(); i++){
            toCheck = floors.get(i);
            if(toCheck.getName().compareTo(name) == 0){
                return toCheck;
            }
        }
        return null;
    }
}
